<?php

namespace app\factory\controller;

use app\common\respond\HttpApi;
use app\factory\logic\MachineLogic;

class MachineController
{
    /**
     * @Description 获取机器信息
     * @author: zj
     * @param HttpApi $respond
     * @time 2024/03/11 12:20:05
     * @return \think\response\Json
     */
    public function info(HttpApi $respond)
    {
        $param = [
            'machine_code' => request()->post('machine_code')
        ];
        $rule = [
            'machine_code' => 'require|max:16'
        ];
        validate($rule)->check($param);

        $logic = new MachineLogic();
        $data = $logic->getInfo($param['machine_code']);

        return $respond->success($data);
    }

    /**
     * @Description 信息上报
     * @author: zj
     * @param HttpApi $respond
     * @time 2024/03/11 15:47:44
     * @return \think\response\Json
     */
    public function report(HttpApi $respond)
    {
        $param = [
            'machine_code' => request()->post('machine_code'),
            'machine_version' => request()->post('machine_version'),
        ];
        $rule = [
            'machine_code' => 'require|max:16',
            'machine_version' => 'require',
        ];
        validate($rule)->check($param);

        $logic = new MachineLogic();
        $logic->report($param['machine_code'],$param['machine_version']);

        return $respond->success([]);
    }

}